package com.ys.enume.storage;

import java.util.ArrayList;
import java.util.List;

/**
 * 物流综合管理
 */
public class TccLogisticsComprehensiveEnum {

	/**
	 * 物流状态
	 */
	public enum Status {
		CANCEL("物流计划已取消", 0),
		EMPTY("空", 1),
		GENERATED("物流订单已生成", 2),
		BERECONCILED("物流订单待对账", 3),
		ISRECONCILIATION("物流订单已对账", 4),
		ISPAY("物流订单已付款", 5),

		;
		public String name;
		public Integer value;

		private Status(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (Status e : Status.values()) {
				if (e.value == value) {
					return e.name;
				}
			}

			return "";
		}
	}



	/**
	 * 运费计算方式
	 */
	public enum FreightMethod {
		BY_ORDER("按物流订单", 0),
		BY_INVOICE("按物流发票", 1),
		;
		public String name;
		public Integer value;

		private FreightMethod(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (FreightMethod e : FreightMethod.values()) {
				if (e.value == value) {
					return e.name;
				}
			}

			return "";
		}
	}

	/**
	 * 物流订单对账
	 */
	public enum LogOrderStatusDz {
		EMPTY("空", 0),
		PROFIT("盈利", 1),
		LOWPROFIT("低利润", 2),
		DEFICIT("亏损", 3),
		;
		public String name;
		public Integer value;

		private LogOrderStatusDz(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (Status e : Status.values()) {
				if (e.value == value) {
					return e.name;
				}
			}

			return "";
		}
	}

	/**
	 * 物流付款状态
	 */
	public enum LogPayStatusZf {
		EMPTY("空", 0),
		INCOMPLETE("未完整", 1),
		COMPLETE("已完整", 2),
		;
		public String name;
		public Integer value;

		private LogPayStatusZf(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (Status e : Status.values()) {
				if (e.value == value) {
					return e.name;
				}
			}

			return "";
		}
	}

	/**
	 * 关税付款状态
	 */
	public enum TariffPayStatus {
		EMPTY("空", 0),
		INCOMPLETE("未完整", 1),
		COMPLETE("已完整", 2),
		;
		public String name;
		public Integer value;

		private TariffPayStatus(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (Status e : Status.values()) {
				if (e.value == value) {
					return e.name;
				}
			}

			return "";
		}
	}


	/**
	 * 关税状态
	 */
	public enum TariffZfStatus {
		EMPTY("无需处理", 0),
		DUTYPENDING("待关税", 1),
		COMPLETE("已关税", 2),
		;
		public String name;
		public Integer value;

		private TariffZfStatus(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (Status e : Status.values()) {
				if (e.value == value) {
					return e.name;
				}
			}

			return "";
		}
	}




	/**
	 * api下单状态
	 */
	public enum ApiPlaceOrderStatus {
		EMPTY("空", 0),
		SUCCESS("成功（匹配）",1),
		WAIT_SEND("待发传",2),
		NO_FIT("不匹配",3),
		CANCEL("取消",4),
		;
		public String name;
		public Integer value;

		private ApiPlaceOrderStatus(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (Status e : Status.values()) {
				if (e.value == value) {
					return e.name;
				}
			}
			return "";
		}

		//拼接
		public static String getNameStrByList(List<ApiPlaceOrderStatus> list) {
			StringBuilder res = new StringBuilder();
			for(ApiPlaceOrderStatus item:list){
				if(res.length()>0){
					res.append("、");
				}
				res.append(item.name);
			}
			return res.toString();
		}
//		public static String getValueSearchByList(List<ApiPlaceOrderStatus> list) {
//			StringBuilder res = new StringBuilder();
//			for(ApiPlaceOrderStatus item:list){
//				if(res.length()>0){
//					res.append(",");
//				}
//				res.append(item.value);
//			}
//			return res.toString();
//		}

		//验证状态 checkValue 是否包含于 list
		public static boolean checkStatus(List<ApiPlaceOrderStatus> list,Integer checkValue) {
			boolean statusIsPass = false;
			for(ApiPlaceOrderStatus orderStatus:list){
				if(orderStatus.value.equals(checkValue)){
					statusIsPass = true;
					break;
				}
			}
			return statusIsPass;
		}

		//可以进行确认下单的状态
		public static List<ApiPlaceOrderStatus> getConfirmStatus() {
			List<ApiPlaceOrderStatus> list = new ArrayList<>();
			list.add(ApiPlaceOrderStatus.EMPTY);//空
			list.add(ApiPlaceOrderStatus.SUCCESS);//成功（匹配）
			//list.add(ApiPlaceOrderStatus.WAIT_SEND);//待发传
//			list.add(ApiPlaceOrderStatus.CANCEL);//取消
			return list;
		}
		//可以进行确认API下单的状态
		public static List<ApiPlaceOrderStatus> getApiConfirmStatus() {
			List<ApiPlaceOrderStatus> list = new ArrayList<>();
			list.add(ApiPlaceOrderStatus.EMPTY);//空
			list.add(ApiPlaceOrderStatus.CANCEL);//取消
			return list;
		}
		//可以进行订单取消的状态
		public static List<ApiPlaceOrderStatus> getDoCancelStatus() {
			List<ApiPlaceOrderStatus> list = new ArrayList<>();
			list.add(ApiPlaceOrderStatus.EMPTY);//空
			list.add(ApiPlaceOrderStatus.CANCEL);//取消
			return list;
		}



	}


}
